package com.cskaoyan.app.controller;

import com.cskaoyan.app.bean.bo.BrandBo;
import com.cskaoyan.app.bean.common.BasePageInfo;
import com.cskaoyan.app.bean.common.BaseRespVo;
import com.cskaoyan.app.bean.common.CommonData;
import com.cskaoyan.app.bean.po.MarketBrand;
import com.cskaoyan.app.bean.po.MarketRegion;
import com.cskaoyan.app.service.AdminBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 廖平安
 * @CreateTime: 2022-12-29  13:09
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("admin/brand")
public class AdminBrandController {
    @Autowired
    private AdminBrandService adminBrandService;

    @GetMapping("list")
    public BaseRespVo<CommonData<MarketBrand>> list(BasePageInfo info, Integer id, String name) {
        CommonData<MarketBrand> data = adminBrandService.list(info, id, name);
        return BaseRespVo.ok(data);
    }

    @PostMapping("create")
    public BaseRespVo<MarketBrand> create(@RequestBody MarketBrand brand) {
        MarketBrand data = adminBrandService.create(brand);
        return BaseRespVo.ok(data);
    }

    @PostMapping("update")
    public BaseRespVo<MarketBrand> update(@RequestBody MarketBrand brand) {
        MarketBrand data = adminBrandService.update(brand);
        return BaseRespVo.ok(data);
    }
    @PostMapping("delete")
    public BaseRespVo delete(@RequestBody MarketBrand brand) {
        adminBrandService.delete(brand);
        return BaseRespVo.ok();
    }
}
